package bmf.util;

import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class XmlUtil {

	public static Object lerDeString(String xmlString, Class<?> clazz) throws Exception {
		Object object = null;
		
		try {
			
			JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
			Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
			object = unmarshaller.unmarshal(new StringReader(xmlString));
			
		} catch (JAXBException e) {
			// TODO tratar essa excecao
			e.printStackTrace();
		}
		
		return object;
	}
	
}
